SET(GENERATE_PYTHON_BINDINGS "TRUE" CACHE BOOL "Controls generation of Python bindings")

IF(${GENERATE_PYTHON_BINDINGS})

FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})

FIND_PACKAGE(PythonLibs 2.7 EXACT REQUIRED)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)

SET(CMAKE_SWIG_FLAGS "-c++" -D${ARCH})

if(LINUX)
SET(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DLINUX)
elseif(WINDOWS)
SET(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DWINDOWS)
endif()

set(SWIG_FILES
    Voxel.i
)

foreach(file in lists ${SWIG_FILES})
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES SWIG_FLAGS "-builtin")
endforeach()

get_library_output_directory(python2.7 OUTDIR)
set(CMAKE_SWIG_OUTDIR ${OUTDIR})

SWIG_ADD_MODULE(Voxel python ${SWIG_FILES})
SWIG_LINK_LIBRARIES(Voxel voxel ${PYTHON_LIBRARIES})

set_library_output_directory(${SWIG_MODULE_Voxel_REAL_NAME} python2.7)


install(TARGETS ${SWIG_MODULE_Voxel_REAL_NAME}
  DESTINATION lib/python2.7
  COMPONENT voxel_python
)

install(FILES 
  ${CMAKE_BINARY_DIR}/lib/python2.7/Voxel.py
  DESTINATION lib/python2.7
  COMPONENT voxel_python
)
ENDIF()
